#!usr/bin/perl

package CardStack;
use Card;
use strict;

my @cards;

sub new {
	my $class = shift;
	my $self = {};
	if (@_ == 1) {
		setup($_[0]);
	}
	bless $self, $class;
	return $self;
}

sub setup {
	my $init = $_[1];
	$init =~ s/^\s+//;
	$init =~ s/\s+$//;
	$init =~ s/,/ /g;
	$init =~ s/\s+/ /g;
	my @cardStrings = split(/ /, $init);
	my $i = 0;
	while ($i < @cardStrings) {
		$cards[$i] = new Card($cardStrings[$i]);
		$i++;
	}
}

sub add {
	push(@cards, $_[1]);
	}

sub shuffle {
	srand;
	my @new = ();
	while (@cards) {
		push(@new, splice (@cards, rand @cards, 1));
	}
	@cards = @new;
}

sub draw {
	shift (@cards);
}

sub remove {
	splice (@cards, $_[1], 1);
}

sub size {
	my $size = @cards;
	$size;
}

sub print {
	my $i = 0;
	while ($i < @cards) {
		print $cards[$i]->getname();
		if ($i + 1 != @cards) {
			print " ";
		}
		$i++;
	}
}

sub getCards {
	@cards;
}
1;